# -*- coding: utf-8 -*-
"""
@Project: base_python
@File: scrapetest.py
@Author: PC
@Date: 2025/04/29
@Description: 
"""

from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup


html = urlopen('http://www.pythonscraping.com/pages/warandpeace.html')
bs = BeautifulSoup(html, 'html.parser')
# nameList = bs.findAll('span', {'class': 'green'})
# nameList = bs.findAll(['h1','h2','h3','h4','h5','h6'])
# nameList = bs.findAll('span', {'class': {'green', 'red'}})
nameList = bs.findAll(text='the prince')
print(len(nameList))
# for name in nameList:
#     print(name.get_text())

    